import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch((err) => err);
};

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    children:[
      {
        path:'/',
        redirect:'users'
      },
      {
        path:'/users',
        name:'users',
        component:()=>import('../views/car-pages/Audi.vue')
      },
      {
        path:'/questions',
        name:'bmw',
        component:()=>import('../views/car-pages/Bmw.vue')
      },
      {
        path:'/interviewBlog',
        name:'merc',
        component:()=>import('../views/car-pages/Merc.vue')
      },

    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
